//========encoding:utf-8=========
/*
 * @describe:  三目运算符
 * @author:mhao
 * @copyright:chinasoft.cn
 * @date:2020年3月18日   下午8:12:45
 */
package edu.chinasoft.handle;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import edu.chinasoft.pojo.User;
@Controller("handler01")
@RequestMapping("/handler01")
public class Handler01 {
	private Logger logger = LoggerFactory.getLogger(Handler01.class);
	@RequestMapping("/method01.do")
	private void method01(HttpServletRequest request,HttpServletResponse response,String user_name,String user_password) throws IOException {
		// TODO Auto-generated method stub
		logger.info("Handler01>>>method01 start ……");
		User result = new User(user_name,user_password);
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		out.write("用户名："+result.getName()+"。<br>");
		out.write("密码："+result.getPassword()+"。<br>");
		out.flush();
		out.close();
		logger.info("Handler01>>>method01 end ……");
	}
	@RequestMapping("/method02.do")
	private void method02(HttpServletRequest request,HttpServletResponse response,String user_name,String user_password,HttpSession session) throws IOException {
		// TODO Auto-generated method stub
		logger.info("Handler01>>>method02 start ……");
		User result = new User(user_name,user_password);
		session.setAttribute("user", result);
		response.sendRedirect(""+request.getContextPath()+"/jsp/loginsuccess.jsp");
		logger.info("Handler01>>>method02 end ……");
	}
}
